package com.hmall.interceptor;

import feign.RequestInterceptor;
import feign.RequestTemplate;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

/**
 * @Author Mingxi Guo
 * @Create 2022-07-17 9:02
 * @Email guomingxi2018@163.cm
 */

@Component
public class FeignInterceptor implements RequestInterceptor {
    @Override
    public void apply(RequestTemplate template) {
        ServletRequestAttributes requestAttributes = ((ServletRequestAttributes)
                RequestContextHolder.getRequestAttributes());
        template.header("authorization", "2");
    }
}
